/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.proxy.component
{
	/**
	 * 解析返回的HttpProxy的返回值 
	 * 
	 */	
	
	public class PoResult
	{
		private var _xml:XML;
		private var _state:Boolean;
		private var _row:int;
		private var _errorInfo:XML;
		private var _dsName:String;
		private var _dataSource:XML
		private var _table:XML;
		private var _object:XML;
		private var _newRow:String="";
		
		/**
		 * 解析返回的HttpProxy的返回值 
		 * @param xml 服务器返回的xml内容。
		 * 
		 */		
		public function PoResult(xml:XML)
		{
			this.xml = xml;
		} 
		
		/**
		 *  解析构造方法传递的xml参数
		 * @param value
		 * 
		 */		
		public function set xml(value:XML):void
		{
			_xml=value;
			_dataSource=new XML(<db />);
			_state=value["state"].toString()=="1";
			_row=Number(value["row"].toString());
			_dsName=value["dsName"].toString();
			_newRow=value["newRow"].toString();
			_table=XML(value.table);
			_object=XML(value.object);
			_errorInfo=XML(value.errorInfo);
			_dataSource.appendChild(<dsName>{value["dsName"].toString()}</dsName>);
			_dataSource.appendChild(<newRow>{_newRow}</newRow>);
			_dataSource.appendChild(value.table);
		}
		
		/**
		 * 获得新行 
		 * @return 
		 * 
		 */		
		public function get newRow():String{
			return _newRow;
		}
		
		/**
		 * 给出对给出xml解析后的字符
		 * <result>
		 *	 <state>1</state>
		 *	  <dsName></dsName>
		 *	 <errorInfo></errorInfo>
		 *	 <table>
		 *	 <row>
		 *	  <field fieldType="string"></field>
		 *	 </row>
		 *	 </table>
		 *	 <object />
		 *	</result> 
		 * @return 
		 * 
		 */		
		public function get xml():XML{
			return _xml;
		}
		
		/**
		 * 该返回集状态 
		 * @return 1 代表成功 0代表失败
		 * 
		 */		
		public function get state():Boolean{
			return _state;
		}
		
		/**
		 * 返回<table/>数据集下有多少返回行.影响行数；row的个数
		 * @return 
		 * 
		 */		
		public function get row():Number{
			return _row;
		}
		
		/**
		 *  服务名；对应xml中的dsName
		 * @return 
		 * 
		 */		
		public function get dsName():String{
			return _dsName;
		}
		
		/**
		 * 表明;对应xml中的table 
		 * @return 
		 * 
		 */		
		public function get table():XML{
			return _table;
		}
		
		/**
		 * 对象；对应xml中的object 
		 * @return 
		 * 
		 */		
		public function get object():XML{
			return _object;
		}
		
		/**
		 * 请求返回后的错误信息若state为0;对应xml中的errorinfo 
		 * @return 
		 * 
		 */		
		public function get errorInfo():XML{
			return _errorInfo;
		}
		
		/**
		 * 单个表的xml，由dsName和table组成；样式：<ds><dsName/><table><row><field fieldType="">值</field></row></table></ds> 
		 * @return 
		 * 
		 */		
		public function get dataSource():XML{
			return _dataSource;
		}
	}
	
	
}